home *** CD-ROM | disk | FTP | other *** search
/ Gekikoh Dennoh Club 5 / Gekikoh Dennoh Club Vol. 5 (Japan).7z / Gekikoh Dennoh Club Vol. 5 (Japan) (Track 01).bin / internet / tcppack / tcppackb.lzh / include / network.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-07  |  4.9 KB  |  240 lines

  1. /*
  2.  * network.h
  3.  *
  4.  * Copyright (C) 1994 First Class Technology.
  5.  */
  6.  
  7. #ifndef __network_h__
  8. #define __network_h__
  9.  
  10. /* Interface section */
  11. #define LOOPBACK_ADDR ((127 << 24) + 1)
  12. #define MAX_HW_ADDR_LEN    (16)
  13.  
  14. #define IFACE_UP     (1)
  15. #define    IFACE_RUNNING    (2)
  16. #define    IFACE_NOARP    (4)
  17. #define    IFACE_NOTRAIL    (8)
  18. #define    IFACE_BROAD    (16)
  19. #define    IFACE_LOOPBACK    (32)
  20. #define    IFACE_PTP    (64)
  21.  
  22. typedef struct iface {
  23.   struct iface *next;
  24.   char *name;
  25.  
  26.   int (*config) (struct iface *);
  27.   int (*stop) (struct iface *);
  28.   int (*update) (struct iface *);
  29.   int (*send) (struct iface *, void *, long, int, int, int, int);
  30.   int (*output) (struct iface *, char *, char *, long, void *);
  31.   void (*input) (struct iface *, void *);
  32.   int (*fprint) (FILE *, char *);
  33.   int (*sprint) (char *, char *);
  34.   int (*fscan) (FILE *, char *);
  35.   int (*sscan) (char *, char *);
  36.  
  37.   int mtu;
  38.   long my_ip_addr;
  39.   long net_mask;
  40.   long broad_cast;
  41.   short arp_type;
  42.   short arp_ip_type;
  43.   short arp_hw_type;
  44.   int hw_addr_len;
  45.   char my_hw_addr[MAX_HW_ADDR_LEN];
  46.   char my_hw_broad_addr[MAX_HW_ADDR_LEN];
  47.  
  48.   struct iface *forw;
  49.   int flag;
  50.   long ipsndcnt;
  51.   long rawsndcnt;
  52.   long snderrcnt;
  53.   long iprcvcnt;
  54.   long rawrcvcnt;
  55.   long rcverrcnt;
  56.   long collcnt;
  57.   long lastsent;
  58.  
  59.   long data;
  60. } iface;
  61.  
  62. /* domain name section */
  63. struct dns
  64. {
  65.   struct dns *prev;
  66.   struct dns *next;
  67.  
  68.   long address;
  69. };
  70.  
  71. /* type values for resources and queries */
  72. #define    T_A    1
  73. #define    T_NS    2
  74. #define    T_MD    3
  75. #define    T_MF    4
  76. #define    T_CNAME    5
  77. #define    T_SOA    6
  78. #define    T_MB    7
  79. #define    T_MG    8
  80. #define    T_MR    9
  81. #define    T_NULL    10
  82. #define    T_WKS    11
  83. #define    T_PTR    12
  84. #define    T_HINFO    13
  85. #define    T_MINFO    14
  86. #define    T_MX    15
  87. #define    T_TXT    16
  88. #define    T_ANY    255
  89.  
  90. /* Values for class */
  91. #define    C_IN    1
  92. #define C_ANY    255
  93.  
  94. /* Values for opcode */
  95. #define QUERY    0
  96. #define IQUERY    1
  97.  
  98. struct rrec {
  99.   short r_zone;            /* zone number */
  100.   short r_class;        /* class number */
  101.   short r_type;            /* type number */
  102.   unsigned long r_ttl;        /* time to live */
  103.   int r_size;            /* size of data area */
  104.   char *r_data;            /* pointer to data */
  105. };
  106.  
  107. struct hostent
  108. {
  109.   char *h_name;
  110.   char **h_aliases;
  111.   int h_addrtype;
  112.   int h_length;
  113.   char **h_addr_list;
  114. };
  115. #define h_addr  h_addr_list[0]
  116.  
  117. struct netent
  118. {
  119.   char *n_name;
  120.   char **n_aliases;
  121.   int n_addrtype;
  122.   unsigned long n_net;
  123. };
  124.  
  125. struct protoent
  126. {
  127.   char *p_name;
  128.   char **p_aliases;
  129.   int p_proto;
  130. };
  131.  
  132. struct servent {
  133.   char *s_name;
  134.   char **s_aliases;
  135.   int s_port;
  136.   char *s_proto;
  137. };
  138.  
  139. /* mib section */
  140. struct mib_entry
  141. {
  142.   char *name;
  143.   union
  144.     {
  145.       long integer;
  146.     } value;
  147. };
  148.  
  149. struct mib_array {
  150.   struct mib_entry* mib;
  151.   int mib_size;
  152.   char *name;
  153. };
  154.  
  155. /* route section */
  156. #define NROUTE 5
  157.  
  158. typedef struct route
  159. {
  160.   struct route *prev;
  161.   struct route *next;
  162.   long target;
  163.   unsigned int bits;
  164.   long gateway;
  165.   long metric;
  166.   struct iface *iface;
  167.   int flags;
  168.   int ttl;
  169.   int _ttl;
  170.   long uses;
  171. } route;
  172.  
  173. typedef route *rtable[32][NROUTE];
  174.  
  175. /* functions */
  176. long _get_version (void);
  177.  
  178. char *search_arp_table (long, int, char *);
  179. void delete_arp_table (long);
  180. void add_arp_table (long, char *);
  181. long *get_arp_array (int *);
  182.  
  183. int isipaddr (char *);
  184. char *n2a_ipaddr (long, char *);
  185. long a2n_ipaddr (char *);
  186. char *n2a_eaddr (char *, char *, int);
  187. char *a2n_eaddr (char *, char *, int);
  188.  
  189. struct hostent *gethostbyname (char *);
  190. struct hostent *gethostbyaddr (char *, int, int);
  191. struct netent *getnetbyname (char *);
  192. struct netent *getnetbyaddr (long, int);
  193. struct servent *getservbyname (char *, char *);
  194. struct servent *getservbyport (int, char *);
  195. struct protoent *getprotobyname (char *);
  196. struct protoent *getprotobynumber (int);
  197.  
  198. iface *get_new_iface (char *);
  199. void link_new_iface (iface *);
  200. long *get_my_ipaddr (int *);
  201. iface *get_iface_list (void);
  202. iface *iface_lookup (long);
  203. iface *iface_lookupn (char *);
  204. int ismyipaddr (long);
  205.  
  206. rtable *rt_top (route **);
  207. route *rt_lookup (long);
  208. route *rt_lookupb (long, unsigned int);
  209. int rt_drop (long, unsigned int);
  210. route *rt_add (long, unsigned int, long, iface *, long, long, char);
  211.  
  212. long *get_sock_array (int *);
  213. char *ntoa_sock (int, int, char *, int);
  214.  
  215. struct mib_array * get_mib_list (void);
  216.  
  217. int dns_add (long);
  218. int dns_drop (long);
  219. struct dns *dns_get (void);
  220. int set_domain_name (char *);
  221. char *get_domain_name (void);
  222. int res_query (char *, int, int, unsigned char *, int);
  223. int res_search (char *, int, int, unsigned char *, int);
  224. int res_mkquery (int, char *, int, int, char *, int, struct rrec *, char *, int);
  225. int res_send (char *, int, char *, int);
  226.  
  227. unsigned long htonl (unsigned long);
  228. unsigned short htons (unsigned short);
  229. unsigned long ntohl (unsigned long);
  230. unsigned short ntohs (unsigned short);
  231.  
  232. enum {
  233.   RIP_ON = 0,
  234.   RIP_OFF,
  235.   RIP_STAT,
  236. };
  237.  
  238. int rip_set (int);
  239. #endif
  240.